package act.impl;

import dao.DAOFactory;
import dao.tro.Airport;
import dao.tro.Country;
import frwa.ActionResult;
import frwa.IAction;

import javax.servlet.http.HttpServletRequest;
import java.util.List;

public class Index implements IAction {

    @Override
    public String getName() {
        return "Index";
    }

    @Override
    public ActionResult perform(HttpServletRequest request) {
        DAOFactory factory = DAOFactory.getDAOFactory(1);
        //List<Airport> airportList = factory.getAirportDAO().allAirportList();
        //List<Country> countryList = factory.getCountryDAO().allCountryList();
        ActionResult actionResult = new ActionResult();
        actionResult.setUrlAddress("index.jsp");
//        if (airportList!=null && countryList!=null) {
//            actionResult.setUrlAddress("/index.jsp");
//        } else {
//            actionResult.setUrlAddress("flt/FlightNotFound.jsp");
//        }
        AirportCountryFormObject airportCountryFormObject = new AirportCountryFormObject();
        //airportCountryFormObject.setAirportList(airportList);
        //airportCountryFormObject.setCountryList(countryList);
        actionResult.setFormObject(airportCountryFormObject);
        return actionResult;
    }
}
